from typing import *


class Solution:

    def waysToBuyPensPencils(self, total: int, cost1: int, cost2: int) -> int:
        dp = [0] * (total + 1)
        dp[0] = 1
        for i in range(1, total + 1):
            if i - cost1 >= 0:
                dp[i] += dp[i - cost1]
            if i - cost2 >= 0:
                dp[i] += dp[i - cost2]
            dp[i] += dp[i - 1] if i > 0 else 0
        return dp[total]


# class Solution:

#     def waysToBuyPensPencils(self, total: int, cost1: int, cost2: int) -> int:
#         ans = 0
#         for i in range(total // cost1 + 1):
#             ans += (total - cost1 * i) // cost2 + 1
#         return ans


s = Solution()
print(s.waysToBuyPensPencils(total=20, cost1=10, cost2=5))
